package cn.wolfcode.springcloud.feign;

import cn.wolfcode.springcloud.domain.Product;
import cn.wolfcode.springcloud.feign.hystrix.ProductFeignHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
//feign客户端用来取代ribbon实现远程调用
//name表示服务名
//fallback告诉降级方法在哪
@FeignClient(name = "PRODUCT-SERVER",fallback =ProductFeignHystrix.class)

public interface IProductFeignApi {
    //访问指定服务的具体接口
    //此处表示访问product-server服务的/products/get/{id}接口
    @GetMapping("/products/get/{id}")
    //@PathVariable("id")里面不加id可能会报空指针
    Product get(@PathVariable("id") Long id);
}
